/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2012 All Rights Reserved.
 */
package com.alipay.supergw.common.dal.share_supergw.auto.ibatis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.alipay.supergw.common.dal.share_supergw.auto.daointerface.FrontCommunicationDAO;
import com.alipay.supergw.common.dal.share_supergw.auto.dataobject.FrontCommunicationDO;

/**
 * An ibatis based implementation of dao interface <tt>com.alipay.supergw.common.dal.share_supergw.auto.daointerface.FrontCommunicationDAO</tt>.
 *
 * This file is generated by <tt>supergw-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>supergw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/sgw_front_communication.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>supergw-dalgen</tt> 
 * to generate this file.
 */
public class IbatisFrontCommunicationDAO extends SqlMapClientDaoSupport implements
                                                                       FrontCommunicationDAO {

    /**
     *  Insert one <tt>FrontCommunicationDO</tt> object to DB table <tt>sgw_front_communication</tt>, return primary key
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>insert into sgw_front_communication(id,direction,channel_system_id,protocol,url,timeout,protocol_params,gmt_create,gmt_modified) values (?, ?, ?, ?, ?, ?, ?, sysdate, sysdate)</tt>
     *
     *	@param frontCommunication
     *	@return int
     *	@throws DataAccessException
     */
    @Override
    public String insert(FrontCommunicationDO frontCommunication) throws DataAccessException {
        if (frontCommunication == null) {
            throw new IllegalArgumentException("Can't insert a null data object into db.");
        }

        getSqlMapClientTemplate().insert("MS-FRONT-COMMUNICATION-INSERT", frontCommunication);

        return frontCommunication.getId();
    }

    /**
     *  Query DB table <tt>sgw_front_communication</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select id, direction, channel_system_id, protocol, url, timeout, protocol_params, gmt_create, gmt_modified from sgw_front_communication where ((id = ?) AND (channel_system_id = ?))</tt>
     *
     *	@param id
     *	@param channelSystemId
     *	@return List<FrontCommunicationDO>
     *	@throws DataAccessException
     */
    @Override
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public List<FrontCommunicationDO> select(String id, String channelSystemId)
                                                                               throws DataAccessException {
        Map param = new HashMap();

        param.put("id", id);
        param.put("channelSystemId", channelSystemId);

        return getSqlMapClientTemplate().queryForList("MS-FRONT-COMMUNICATION-SELECT", param);

    }

    /**
     *  Update DB table <tt>sgw_front_communication</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>update sgw_front_communication set direction=?, channel_system_id=?, protocol=?, url=?, timeout=?, protocol_params=?, gmt_modified=sysdate where (id = ?)</tt>
     *
     *	@param frontCommunication
     *	@return int
     *	@throws DataAccessException
     */
    @Override
    public int update(FrontCommunicationDO frontCommunication) throws DataAccessException {
        if (frontCommunication == null) {
            throw new IllegalArgumentException("Can't update by a null data object.");
        }

        return getSqlMapClientTemplate()
            .update("MS-FRONT-COMMUNICATION-UPDATE", frontCommunication);
    }

    /**
     *  Delete records from DB table <tt>sgw_front_communication</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>delete from sgw_front_communication where (id = ?)</tt>
     *
     *	@param id
     *	@return int
     *	@throws DataAccessException
     */
    @Override
    public int delete(String id) throws DataAccessException {
        Integer param = new Integer(id);

        return getSqlMapClientTemplate().delete("MS-FRONT-COMMUNICATION-DELETE", param);
    }

}